USE [CompanyDic]
GO
/****** Object:  Table [dbo].[Category]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Category](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Code] [nvarchar](9) NULL,
 CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Area]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Area](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Code] [nvarchar](9) NULL,
 CONSTRAINT [PK_Area] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Kind]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Kind](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Code] [nvarchar](9) NULL,
 CONSTRAINT [PK_Kind] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Industry]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Industry](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Code] [nvarchar](9) NULL,
 CONSTRAINT [PK_Industry] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[User]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[Email] [nvarchar](50) NOT NULL,
	[LoginName] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
	[TotalMark] [int] NOT NULL,
	[Role] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[UpdateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Size]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Size](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Code] [nvarchar](9) NULL,
 CONSTRAINT [PK_Size] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Organization]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Organization](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
	[Address] [nvarchar](200) NOT NULL,
	[Zipcode] [nvarchar](10) NULL,
	[Site] [nvarchar](100) NULL,
	[Email] [nvarchar](50) NULL,
	[Tel] [nvarchar](20) NULL,
	[CategoryId] [int] NULL,
	[IndustryId] [int] NULL,
	[KindId] [int] NULL,
	[SizeId] [int] NULL,
	[AreaId] [int] NULL,
	[Domain] [nvarchar](100) NULL,
	[LatLng] [nvarchar](20) NULL,
	[TotalMark] [int] NULL,
	[DeleteFlag] [char](1) NULL,
	[CreateDate] [datetime] NOT NULL,
	[UpdateDate] [datetime] NOT NULL,
	[CreateBy] [int] NOT NULL,
	[UpdateBy] [int] NOT NULL,
 CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[UserTrack]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UserTrack](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[OrgId] [int] NULL,
	[UserId] [int] NULL,
	[Ip] [nvarchar](50) NULL,
	[CreateDate] [datetime] NULL,
 CONSTRAINT [PK_UserTrack] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OrgBrief]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrgBrief](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Brief] [nvarchar](2000) NULL,
 CONSTRAINT [PK_OrgBrief] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OrganizationTemp]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[OrganizationTemp](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ParentId] [int] NULL,
	[Name] [nvarchar](100) NOT NULL,
	[Address] [nvarchar](200) NOT NULL,
	[Zipcode] [nvarchar](10) NULL,
	[Site] [nvarchar](100) NULL,
	[Email] [nvarchar](50) NULL,
	[Tel] [nvarchar](20) NULL,
	[CategoryId] [int] NULL,
	[IndustryId] [int] NULL,
	[KindId] [int] NULL,
	[SizeId] [int] NULL,
	[AreaId] [int] NULL,
	[Domain] [nvarchar](100) NULL,
	[LatLng] [nvarchar](20) NULL,
	[TotalMark] [int] NULL,
	[DeleteFlag] [char](1) NULL,
	[CreateDate] [datetime] NOT NULL,
	[UpdateDate] [datetime] NOT NULL,
	[CreateBy] [int] NOT NULL,
	[UpdateBy] [int] NOT NULL,
 CONSTRAINT [PK_OrganizationTemp] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Comment]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Comment](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[OrgId] [int] NOT NULL,
	[Mark] [int] NOT NULL,
	[Content] [nvarchar](2000) NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[CreateBy] [int] NOT NULL,
 CONSTRAINT [PK_Comment] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OrgBriefTemp]    Script Date: 01/07/2012 11:07:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrgBriefTemp](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Brief] [nvarchar](2000) NULL,
 CONSTRAINT [PK_OrgBriefTemp] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_Comment_CreateUser]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[Comment]  WITH CHECK ADD  CONSTRAINT [FK_Comment_CreateUser] FOREIGN KEY([CreateBy])
REFERENCES [dbo].[User] ([Id])
GO
ALTER TABLE [dbo].[Comment] CHECK CONSTRAINT [FK_Comment_CreateUser]
GO
/****** Object:  ForeignKey [FK_Comment_Organization]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[Comment]  WITH CHECK ADD  CONSTRAINT [FK_Comment_Organization] FOREIGN KEY([OrgId])
REFERENCES [dbo].[Organization] ([Id])
GO
ALTER TABLE [dbo].[Comment] CHECK CONSTRAINT [FK_Comment_Organization]
GO
/****** Object:  ForeignKey [FK_Organization_Area]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[Organization]  WITH CHECK ADD  CONSTRAINT [FK_Organization_Area] FOREIGN KEY([AreaId])
REFERENCES [dbo].[Area] ([Id])
GO
ALTER TABLE [dbo].[Organization] CHECK CONSTRAINT [FK_Organization_Area]
GO
/****** Object:  ForeignKey [FK_Organization_Category]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[Organization]  WITH CHECK ADD  CONSTRAINT [FK_Organization_Category] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[Category] ([Id])
GO
ALTER TABLE [dbo].[Organization] CHECK CONSTRAINT [FK_Organization_Category]
GO
/****** Object:  ForeignKey [FK_Organization_Industry]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[Organization]  WITH CHECK ADD  CONSTRAINT [FK_Organization_Industry] FOREIGN KEY([IndustryId])
REFERENCES [dbo].[Industry] ([Id])
GO
ALTER TABLE [dbo].[Organization] CHECK CONSTRAINT [FK_Organization_Industry]
GO
/****** Object:  ForeignKey [FK_Organization_Size]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[Organization]  WITH CHECK ADD  CONSTRAINT [FK_Organization_Size] FOREIGN KEY([SizeId])
REFERENCES [dbo].[Size] ([Id])
GO
ALTER TABLE [dbo].[Organization] CHECK CONSTRAINT [FK_Organization_Size]
GO
/****** Object:  ForeignKey [FK_OrganizationTemp_Area]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[OrganizationTemp]  WITH CHECK ADD  CONSTRAINT [FK_OrganizationTemp_Area] FOREIGN KEY([AreaId])
REFERENCES [dbo].[Area] ([Id])
GO
ALTER TABLE [dbo].[OrganizationTemp] CHECK CONSTRAINT [FK_OrganizationTemp_Area]
GO
/****** Object:  ForeignKey [FK_OrganizationTemp_Category]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[OrganizationTemp]  WITH CHECK ADD  CONSTRAINT [FK_OrganizationTemp_Category] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[Category] ([Id])
GO
ALTER TABLE [dbo].[OrganizationTemp] CHECK CONSTRAINT [FK_OrganizationTemp_Category]
GO
/****** Object:  ForeignKey [FK_OrganizationTemp_Industry]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[OrganizationTemp]  WITH CHECK ADD  CONSTRAINT [FK_OrganizationTemp_Industry] FOREIGN KEY([IndustryId])
REFERENCES [dbo].[Industry] ([Id])
GO
ALTER TABLE [dbo].[OrganizationTemp] CHECK CONSTRAINT [FK_OrganizationTemp_Industry]
GO
/****** Object:  ForeignKey [FK_OrganizationTemp_Organization]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[OrganizationTemp]  WITH CHECK ADD  CONSTRAINT [FK_OrganizationTemp_Organization] FOREIGN KEY([ParentId])
REFERENCES [dbo].[Organization] ([Id])
GO
ALTER TABLE [dbo].[OrganizationTemp] CHECK CONSTRAINT [FK_OrganizationTemp_Organization]
GO
/****** Object:  ForeignKey [FK_OrganizationTemp_Size]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[OrganizationTemp]  WITH CHECK ADD  CONSTRAINT [FK_OrganizationTemp_Size] FOREIGN KEY([SizeId])
REFERENCES [dbo].[Size] ([Id])
GO
ALTER TABLE [dbo].[OrganizationTemp] CHECK CONSTRAINT [FK_OrganizationTemp_Size]
GO
/****** Object:  ForeignKey [FK_OrgBrief_Organization]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[OrgBrief]  WITH CHECK ADD  CONSTRAINT [FK_OrgBrief_Organization] FOREIGN KEY([Id])
REFERENCES [dbo].[Organization] ([Id])
GO
ALTER TABLE [dbo].[OrgBrief] CHECK CONSTRAINT [FK_OrgBrief_Organization]
GO
/****** Object:  ForeignKey [FK_OrgBriefTemp_OrganizationTemp]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[OrgBriefTemp]  WITH CHECK ADD  CONSTRAINT [FK_OrgBriefTemp_OrganizationTemp] FOREIGN KEY([Id])
REFERENCES [dbo].[OrganizationTemp] ([Id])
GO
ALTER TABLE [dbo].[OrgBriefTemp] CHECK CONSTRAINT [FK_OrgBriefTemp_OrganizationTemp]
GO
/****** Object:  ForeignKey [FK_UserTrack_Organization]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[UserTrack]  WITH CHECK ADD  CONSTRAINT [FK_UserTrack_Organization] FOREIGN KEY([OrgId])
REFERENCES [dbo].[Organization] ([Id])
GO
ALTER TABLE [dbo].[UserTrack] CHECK CONSTRAINT [FK_UserTrack_Organization]
GO
/****** Object:  ForeignKey [FK_UserTrack_User]    Script Date: 01/07/2012 11:07:32 ******/
ALTER TABLE [dbo].[UserTrack]  WITH CHECK ADD  CONSTRAINT [FK_UserTrack_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
ALTER TABLE [dbo].[UserTrack] CHECK CONSTRAINT [FK_UserTrack_User]
GO
